package io.lkt.modules.job.task;

import io.lkt.common.utils.DateUtil;
import io.lkt.modules.sys.service.BUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling   // 2.开启定时任务
public class UserScheduleTask {

    @Autowired
    private BUserInfoService bUserInfoService;

    //12点半一次
    @Scheduled(cron = "0 30 12 * * ?")
    private void updateUsersCensusTasks1230() {
        System.out.println("updateUsersCensusTasks1230开始："+ DateUtil.getCurDate());
        this.bUserInfoService.updateCensus();
        System.out.println("updateUsersCensusTasks1230结束"+ DateUtil.getCurDate());
    }

    //22点30一次
    @Scheduled(cron = "0 30 22 * * ?")
    private void updateUsersCensusTasks2230() {
        System.out.println("updateUsersCensusTasks2230："+ DateUtil.getCurDate());
        this.bUserInfoService.updateCensus();
        System.out.println("updateUsersCensusTasks2230"+ DateUtil.getCurDate());
    }

}
